fix(project): reject empty/whitespace-only --name in create and update#36
fix(project): reject empty/whitespace-only --name in create and update#36lxcario wants to merge 1 commit into
Conversation
project create/update validated --name with the action handler's if (!name) check, which a whitespace-only string passes (a non-empty string is truthy). The blank name was then sent verbatim, creating a junk-named project. The sibling est create already rejects this via the requireString whitespace guard (dogfood P1 fix TestSprite#1); this aligns project create/update with that behavior. Adds 2 regression tests.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
What
testsprite project createandproject updateaccept a whitespace-only--name(e.g.--name " ") and send it to the backend verbatim, creating a blank-named project.Why this matters
A whitespace-only name produces a junk project record that's effectively unidentifiable in
project listand the dashboard. The siblingtest createalready rejects this input, so the two write paths behave inconsistently for the same kind of value.Reproduction
Root cause
src/commands/project.ts. The command action validates the name withif (!cmdOpts.name), which a whitespace-only string passes (a non-empty string is truthy), andrunCreate/runUpdateonly check the upper length bound:There is no lower-bound / whitespace check, so
" "flows straight into the request body.Fix
Reject empty / whitespace-only names in both
runCreateandrunUpdate, before the existing length checks:This mirrors the existing
requireStringwhitespace guard insrc/lib/validate.tsthattest createalready uses (added as "dogfood P1 fix #1" to stop junk records reaching the backend) — the project path just wasn't going through it.Tests
Added 2 tests to
src/commands/project.test.ts(one forrunCreate, one forrunUpdate) asserting a whitespace-only--namerejects withVALIDATION_ERROR/ exit 5 and makes no network call. Both fail onmainbefore this fix and pass after.main):Tests 16 failed | 1359 passed | 72 skippedTests 16 failed | 1361 passed | 72 skipped(+2 new tests)The 16 failures are pre-existing and environment-specific (Windows path/line-ending), unrelated to this change — see #4.
Verification
npm test: same 16 pre-existing (environment-specific) failures as baseline, zero newnpm run typecheck: passnpm run lint: pass